<?php 

if(isset($_POST['submitprotest'])) {

require_once('settings.php');
require_once('classes/db.php');

define('IN_PHPBB', true);
$phpEx = substr(strrchr(__FILE__, '.'), 1);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : $phpbbpath;
include($phpbb_root_path . 'common.' . $phpEx);
include($phpbb_root_path . 'includes/functions_posting.' . $phpEx);
include($phpbb_root_path . 'includes/functions_display.' . $phpEx);
include($phpbb_root_path . 'includes/message_parser.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();

$baninputreason = sanitizeString($_POST['reason']);
$getbanid = sanitizeString($_POST['protestform']);
$getuser = sanitizeString($_POST['hiddenusername']);
$getsteamid = sanitizeString($_POST['hiddensteamid']);
$getlength = sanitizeString($_POST['hiddenlength']);
$getreason = sanitizeString($_POST['hiddenreason']);
$getadmin = sanitizeString($_POST['hiddenadmin']);
$getdate = sanitizeString($_POST['hiddendate']);

$forumusername = $user->data['username'];
$forumuserid = $user->data['user_id'];

$message = "[b]Username:[/b] " . $getuser . "
[b]SteamID:[/b] " . $getsteamid . "
[b]Length:[/b] " . $getlength . "
[b]Reason:[/b] " . $getreason . "
[b]Admin:[/b] " . $getadmin . "
[b]Date/Time:[/b] " . $getdate . "
[b]Protest Reason:[/b] 
" . stripslashes($baninputreason) . "
---------------------
[url=" . $phpbburl . "/sourcebb/bandetails.php?banid=" . $getbanid . "][b]Ban Info[/b][/url]";

$contested = request_var('contested', 0);

$time = time();

$rawsubject = "Ban Protest: " . $getuser;
$my_subject	= utf8_normalize_nfc($rawsubject, '', true);
$my_text	= utf8_normalize_nfc($message, '', true);

$poll = $uid = $bitfield = $options = ''; 

generate_text_for_storage($my_subject, $uid, $bitfield, $options, false, false, false);
generate_text_for_storage($my_text, $uid, $bitfield, $options, true, true, true);

$data = array( 
	'forum_id'		=> $protestforum,
	'icon_id'		=> false,

	'enable_bbcode'		=> true,
	'enable_smilies'	=> true,
	'enable_urls'		=> true,
	'enable_sig'		=> true,

	'message'		=> $my_text,
	'message_md5'	=> md5($my_text),
				
	'bbcode_bitfield'	=> $bitfield,
	'bbcode_uid'		=> $uid,

	'post_edit_locked'	=> 0,
	'topic_title'		=> $my_subject,
	'notify_set'		=> false,
	'notify'			=> false,
	'post_time' 		=> 0,
	'forum_name'		=> '',
	'enable_indexing'	=> true,
	'topic_first_poster_name'		=> $forumusername,
);

submit_post('post', $my_subject, $forumusername, POST_NORMAL, $poll, $data);
redirect($phpbb_root_path . "index.php");
}
?>